package com.bjc.principle.visitor;

/**
 * @program: DesignPattern
 * @description:
 * @author: bjc
 * @create: 2021-01-04 18:36
 */
public class Computer implements ComputerPart{

    ComputerPart[] parts;

    public Computer(){
        parts = new ComputerPart[] {new Mouse(), new KeyBoard(), new Monitor()};
    }


    @Override
    public void accept(ComputerPartVisitor computerPartVisitor) {
        for (int i = 0; i < parts.length; i++) {
            parts[i].accept(computerPartVisitor);
        }
        computerPartVisitor.visit(this);
    }
}
